#include "StdAfx.h"
#include <Layer>
#include <LayerManager>

Layer::Layer(QPointer<LayerManager> layerManager, const QString& strName, bool bMainLayer /*= false*/, QObject *parent /*= 0*/)
	: QObject(parent)
	, m_layerManager(layerManager)
	, m_name(strName)
	, m_bMainLayer(bMainLayer)
	, m_backColor(Qt::white)
{

}

Layer::~Layer()
{

}

const QString& Layer::name() const
{
	return m_name;
}

void Layer::paint( QPainter& painter )
{
	Q_ASSERT(m_layerManager);
	QRect rect(0, 0, m_layerManager->size().width(), m_layerManager->size().height());

	painter.save();
	painter.setPen(QPen(Qt::DotLine));
	painter.drawRect(rect);
	painter.restore();

	if(isMainLayer())
	{
		painter.fillRect(rect, m_backColor);	
	}
}

bool Layer::isMainLayer() const
{
	return m_bMainLayer;
}
